﻿using UnityEngine;
using System.Collections;
using Dict.DataModel;
using ProtoBuf.Message;

namespace Room
{
    public class RCUIUnionMine : RCUIBase
    {
        float arriveRange = 0.8f;
        public RCUIUnionMine(RoomCharactor owner)
            : base(owner)
        {
            this.owner = owner;
            type = UIType.UnionMine;
            ClickRange = (float)Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.UnionFightCanClickResRange;
            arriveRange = (float)Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.UnionFightArriveResourcePointDistance;
        }
        

        protected override void OnClick()
        {
            var self = owner.charactorManager.GetSelfCharactor();
            var ai = self.ai as RCAIUnionSelf;
            if (ai != null && ai.IdleState() )
            {
                ai.AutoGoto(owner.transform.position, () =>
                {
                    if (ai.IdleState())
                    {
                        var net = Room.RoomManager.currentRoom.netManager as RoomNetUnionFight;

                        var _ai = owner.ai as RCAIUnionMine;
                        var guid = _ai.resPoint.guid;

                        net.SendCSUFPlayerCollect(guid);
                    }
                }, arriveRange);
            }
        }

    }
}
